package com.nuc.thread.aqs;

import lombok.extern.slf4j.Slf4j;

/**
 * @author 诗酒趁年华
 * @version 1.0.0
 * @Description
 * @createTime 2021年08月14日 12:02:00
 */
@Slf4j
public class TestAqs {
    public static void main(String[] args) {
        MyLock lock = new MyLock();

        new Thread(()->{
            lock.lock();
            log.debug("locking1...");
            lock.lock();
            log.debug("locking2...");
            try{
                log.debug("locking...");
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            } finally {
                log.debug("unlocking...");
                lock.unlock();
            }

        },"t1").start();

        new Thread(()->{
            lock.lock();
            try{
                log.debug("locking...");
            }finally {
                log.debug("unlocking...");
                lock.unlock();
            }

        },"t2").start();

    }
}
